import { ref } from 'vue'
import { defineStore } from "pinia";
import { getCookie, setCookie } from "@/utils/cookie";

export const Users = defineStore('user', () => {
  const token = ref(getCookie('token') || '')
  const saveToken = (data: string | null) => {
    token.value = data
    setCookie('token', data)
  }
  return { token, saveToken }
})

// 左侧menu当前activePath
export const MenuActivePath = defineStore('menuPath', () => {
  const menuPath = ref(getCookie('path') || 'users')
  const savePath = (data: string) => {
    menuPath.value = data
    setCookie('path', data)
  }
  return { menuPath, savePath }
})